diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2023-03-28 19:26:30 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2023-03-28 19:26:30 +0200 |
| commit | c3c90d575182d64b0e679e8da81a6d4f3559cf1f (patch) | |
| tree | e1ad938d658e6c80c1392bca86d0755f47064882 /pages/av/[id].js | |
| download | next-list-app-c3c90d575182d64b0e679e8da81a6d4f3559cf1f.tar.gz next-list-app-c3c90d575182d64b0e679e8da81a6d4f3559cf1f.tar.zst next-list-app-c3c90d575182d64b0e679e8da81a6d4f3559cf1f.zip | |
Diffstat (limited to 'pages/av/[id].js')
| -rw-r--r-- | pages/av/[id].js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pages/av/[id].js b/pages/av/[id].js new file mode 100644 index 0000000..36db22d --- /dev/null +++ b/pages/av/[id].js @@ -0,0 +1,30 @@ +import Link from "next/link"; +import Avatar from "../../components/Avatar" + +export default function Av(props) { + console.log(props) + return ( + <> + <h1><Link href="/">Go back home</Link></h1> + {<Avatar data={props.av} full={true} key={props.av.id} />} + </> + ) +} + +export async function getStaticProps({ params }) { + const av = await fetch(`http://localhost:3000/api/avatars/${params.id}`).then(res => res.json()); + return { + props: { + av + } + } +} + +export async function getStaticPaths() { + const res = await fetch(`http://localhost:3000/api/avatars`).then(res => res.json()); + console.log("getStaticPaths ", res) + return { + paths: res.map(av => `/av/${av.id}`), + fallback: true, + } +} |
